package com.open.capacity.employee.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.open.capacity.common.model.SysUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


@Mapper
public interface ConcurrentDao extends BaseMapper<SysUser> {

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into sys_user(username, password, nick_name , head_img_url, phone, sex, enabled, type, create_time, update_time, account_type) "
            + "values(#{username}, #{password}, #{nickname}, #{headImgUrl}, #{phone}, #{sex}, #{enabled}, #{type}, #{createTime}, #{updateTime}, #{accountType})")
    int save(SysUser sysUser);

    int updateByPrimaryKey(SysUser sysUser);

    @Select("select id ,username, password,nick_name nickname, head_img_url headImgUrl , phone, sex, enabled, type, create_time createTime, account_type accountType  , update_time updateTime from sys_user t where t.username = #{username}")
    SysUser findByUsername(String username);

    @Select("select id ,username, password,nick_name nickname, head_img_url headImgUrl , phone, sex, enabled, type, create_time createTime , account_type accountType , update_time updateTime from sys_user t where t.id = #{id}")
    SysUser findById(Long id);

    @Select("select id ,username, password,nick_name nickname, head_img_url headImgUrl , phone, sex, enabled, type, create_time createTime , account_type accountType , update_time updateTime  from sys_user u   where u.username = #{username}")
    SysUser findUserByUsername(String username);

    @Select("select id ,username, password,nick_name nickname, head_img_url headImgUrl , phone, sex, enabled, type, create_time createTime , account_type accountType , update_time updateTime  from sys_user u   where u.phone = #{mobile}")
    SysUser findUserByMobile(String mobile);

    int count(Map<String, Object> params);

    List<SysUser> findList(Map<String, Object> params);


}
